﻿using System;
using System.Collections.Generic;
using MyFloridaHouse.libSTO;
using MyFloridaHouse.DataAccess;
using MyFloridaHouse.libSvCommonUtilities;
using MyFloridaHouse.libSvUtilities;
using MyFloridaHouse.libSvDTO;

namespace MyFloridaHouse.libServiceBusinessRules
{
	/// <summary>
	/// District Data Summary
	/// </summary>
    public static class DistrictDataSummary
    {
		/// <summary>
		/// Gets the district data summary.
		/// </summary>
		/// <param name="iDistrictID">The idistrictID.</param>
		/// <param name="compressediRegionIDList">The compressediregionID list.</param>
		/// <param name="iSourceLayerIDList">The isourcelayerID list.</param>
		/// <param name="iDictionaryIDList">The idictionaryID list.</param>
		/// <returns>Object: <see cref="DistrictShapeSTO"/></returns>
        public static DistrictDataSummarySTO GetDistrictDataSummary(int iDistrictID, byte [] compressediRegionIDList, string iSourceLayerIDList, string iDictionaryIDList)
        {
            DAL_CensusData dal = new DAL_CensusData();
            DistrictDataSummarySTO results = new DistrictDataSummarySTO();
            results.districtID = iDistrictID;
            try
            {
                string iRegionIDList = CompressionManager.Decompress(compressediRegionIDList); //this is the regionID list
                if (iRegionIDList.Equals("")) //check to see if an empty region list is passed in
                {
                    results.districtDataSummaryList = new List<RegionDataDTO>();
                }
                else
                {
                    results.districtDataSummaryList = DistrictData.GetDistrictData(iDistrictID, iRegionIDList, iSourceLayerIDList, iDictionaryIDList);
					//Todo: make sure the source called here is fixed (has unreachable code.)
                }
            }
            catch (Exception ex)
            {
                results.errorMessage = ex.Message;
                return results;
            }
            return results;
        }
    }
}
